#include <iostream>
#include <map>
#include <ctime>
#include <string>


const int SZ = 1e8;
char buf[SZ];
int ps; 
void * operator new (size_t x) 
{ 
	ps += x; 
	if (ps > SZ) throw 42; 
	return buf + ps - x; 
} 
void operator delete(void *x) { }


const int MAXLEN = 600000; //8e6;
char s[MAXLEN];
int size;
int pos[MAXLEN], len[MAXLEN], par[MAXLEN];
std::map<char,int> to[MAXLEN], wlink[MAXLEN];
int sz = 2;

void attach(int child, int parent, char c, int child_len)
{
	to[parent][c] = child;
	len[child] = child_len;
	par[child] = parent;
}
void extend(char c)
{
	int p, i = size;
	for (p = sz - 1; !wlink[p].count(c); p = par[p])
		i -= len[p];
	int v = wlink[p][c];
	if (to[v].count(s[i]))
	{
		char cu = s[i];
		int u = to[v][cu];
		for (pos[sz] = pos[u] - len[u]; s[pos[sz]] == s[i]; pos[sz] += len[p], i += len[p])
			p = to[p][s[i]];
		attach(sz, v, cu, len[u] - (pos[u] - pos[sz]));
		attach(u, sz, s[pos[sz]], pos[u] - pos[sz]);
		v = wlink[p][c] = sz++;
	}
	attach(sz, v, s[i], size - i);
	pos[sz++] = size;
}

int main()
{
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	len[1] = 1; pos[1] = 0; par[1] = 0;
	for (int c = 0; c <= 255; c++)
		to[0][c] = wlink[0][c] = 1; 

	std::cin >> s;
	size = strlen(s) + 1;
	s[size - 1] = '$';
	long long ans = 0;
	for (int i = size - 1; i >= 0; i--)
		extend(s[i]);
    for(int i = 2; i < sz; i++)
		ans += len[i];
    std::cout << ans - size << "\n";
}
